package com.hua.yuan;

import android.app.Application;
import android.os.StrictMode;
import android.support.annotation.NonNull;
import com.hua.yuan.common.https.OkHttpModule;
import com.hua.yuan.common.permission.PermissionModule;
import com.hua.yuan.http.BaseUrl;
import com.hua.yuan.manager.user.UserManagerModule;
import com.hua.yuan.userlogin.UserLoginModule;
import com.tencent.rtmp.TXLiveBase;

import cm.hua.yuan.common.utils.AppContextManager;

/**
 * @Author: richsjeson.
 * @Description: 应用管理类
 * @Date:Created in 2018/12/30 12:58 PM.
 * @Modified By:
 */
public class ApplicationManager {


    private static ApplicationManager mInstance;


    public static  ApplicationManager getInstance(){

        if(mInstance == null){
            mInstance=new ApplicationManager();
        }
        return mInstance;
    }

    public void init(@NonNull Application pApplication){
        TXLiveBase.setConsoleEnabled(false);
        TXLiveBase.setAppID("1400120590");
        AppContextManager.getInstance().init(pApplication.getApplicationContext(),pApplication);
        OkHttpModule.getInstance().init(BaseUrl.BASE_URL);
        UserLoginModule.getInstance().init();
        UserManagerModule.getInstance().init();
//        StrictMode.ThreadPolicy threadPolicy = new StrictMode.ThreadPolicy.Builder()
//                .detectAll()
//                .penaltyLog()
//                .build();
//        StrictMode.setThreadPolicy(threadPolicy);
//
//        StrictMode.VmPolicy vmPolicy = new StrictMode.VmPolicy.Builder()
//                .detectAll()
//                .penaltyLog() // Must!
//                .build();
//        StrictMode.setVmPolicy(vmPolicy);
    }
    public void release() {
        AppContextManager.getInstance().relase();
        UserLoginModule.getInstance().release();
        UserManagerModule.getInstance().release();
    }
}
